From: Tim Starling Date: Wed, 19 Oct 2005 12:12:14 +0000 (+0000) Subject: Maximum image area X-Git-Tag: 1.6.0~1394 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=5f06fd85061aabc392eeba2861a7ee24af5a700d;p=lhc%2Fweb%2Fwiklou.git Maximum image area --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ef5d7b058c..fb7c2d6a98 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -157,6 +157,8 @@ fully support the editing toolbar, but was found to be too confusing. (requires PHP 5, XMLReader extension) * (bug 2773) Print style sheet no longer overrides RTL text direction * (bug 2938) Update MediaWiki:Exporttext to be more general +* Fixed possible infinite loop in formatComment +* Added a limit to the size of image files which can be thumbnailed === Caveats === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4ab0c3bc96..2abb7788ec 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1126,6 +1126,12 @@ $wgSVGConverter = 'ImageMagick'; $wgSVGConverterPath = ''; /** Don't scale a SVG larger than this unless its native size is larger */ $wgSVGMaxSize = 1024; +/** + * Don't thumbnail an image if it will use too much working memory + * Default is 50 MB if decompressed to RGBA form, which corresponds to + * 12.5 million pixels or 3500x3500 + */ +$wgMaxImageArea = 1.25e7; /** Set $wgCommandLineMode if it's not set already, to avoid notices */ if( !isset( $wgCommandLineMode ) ) { diff --git a/includes/Image.php b/includes/Image.php index 2ec5490327..ffd647c764 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -919,6 +919,7 @@ class Image function renderThumb( $width, $useScript = true ) { global $wgUseSquid, $wgInternalServer; global $wgThumbnailScriptPath, $wgSharedThumbnailScriptPath; + global $wgSVGMaxSize, $wgMaxImageArea; $fname = 'Image::renderThumb'; wfProfileIn( $fname ); @@ -940,7 +941,14 @@ class Image return null; } - global $wgSVGMaxSize; + # Don't thumbnail an image so big that it will fill hard drives and send servers into swap + # JPEG has the handy property of allowing thumbnailing without full decompression, so we make + # an exception for it. + if ( $this->getMimeType() !== "image/jpeg" && $this->width * $this->height > $wgMaxImageArea ) { + wfProfileOut( $fname ); + return null; + } + $maxsize = $this->mustRender() ? max( $this->width, $wgSVGMaxSize ) : $this->width - 1;